import { EventName } from "../../public/Config";
import GlobalEvent from "../../cfw/event/GlobalEvent";
import SDKManager from "../SDKManager";
import BornController from "../../game/born/BornController";

// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class StartAdView extends cc.Component {


    onLoad() {
        GlobalEvent.instance().on(EventName.ZS_DATA, this.updateContent, this)
    }

    onDestroy() {
        GlobalEvent.instance().off(EventName.ZS_DATA, this.updateContent, this)
    }

    updateContent() {
        if (!cc.isValid(this.node)) {
            return;
        }
        if (SDKManager.getChannel().getzs_loading_video()) {
            SDKManager.getChannel().showRewardAd(0, () => {
                BornController.instance().intoLayer()
            })
        }
    }

    // update (dt) {}
}
